package com.share.disruptor.trade;

import com.lmax.disruptor.EventHandler;
import com.lmax.disruptor.WorkHandler;

import java.util.UUID;

/**
 * @desc:   参考：https://blog.csdn.net/qq_33589510/article/details/109007314
 * @author:caifan
 * @date:2021/5/22
 */
public class TradeHandler implements EventHandler<Trade>, WorkHandler<Trade> {
    @Override
    public void onEvent(Trade event, long sequence, boolean endOfBatch) throws Exception {
        // 生成订单id
        event.setId(UUID.randomUUID().toString());
        System.out.println(event);
    }

    @Override
    public void onEvent(Trade event) throws Exception {
        this.onEvent(event);
    }

}
